package cn.tedu.csmall.all.adapter.consumer;

import cn.tedu.csmall.all.service.ICartService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ScopeMetadata;
import org.springframework.stereotype.Component;

/**
 * @author java@tedu.cn
 * @version 1.0
 */
@Component
@RocketMQMessageListener(
        topic="order-add-topic",
        consumerGroup = "${rocketmq.consumer.group}",
        selectorExpression = "*")
public class CartDeleteConsumerListener implements RocketMQListener<String> {
    @Autowired
    private ICartService cartService;
    @Override
    public void onMessage(String msg) {
        String userId=msg.split(":")[0];
        String commodityCode=msg.split(":")[1];
        //删除购物车
        cartService.deleteUserCart(userId, commodityCode);
    }
}
